package com.itheima.shop.decorator_review;

import com.itheima.shop.dao.OrderDao;
import com.itheima.shop.domain.Order;
import com.itheima.shop.service.ItemService;
import com.itheima.shop.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

/**
 * @program: design
 * @description:
 * @author: zhanghz001
 * @create: 2021-02-27 15:53
 **/
@Service
public class OrderServiceReviewImpl implements OrderService {
    @Autowired
    private OrderDao orderDao;
    
    @Autowired
    private ItemService itemService;
    @Autowired
    private MoneySumReview orderMoneySumReview;
    @Autowired
    @Qualifier("fullMoneySumReview")
    private DecoratorReview vipMoneySumReview;
    @Autowired
    @Qualifier("fullMoneySumReview")
    private DecoratorReview fullMoneSumReview;
    
    @Override
    public int add(Order order) {
        //vip减五元
        vipMoneySumReview.setMoneySumReview(orderMoneySumReview);
        //满100减10元
        fullMoneSumReview.setMoneySumReview(vipMoneySumReview);
        fullMoneSumReview.sum(order);
        
        //修改库存
        int mCount = itemService.modify(order.getNum(), order.getItemId());
        //添加订单
        int addCount = orderDao.add(order);
        return addCount;
    }
    
    @Override
    public void cancelOrder(String id) {
        //只是
    }
}
